<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>7基础语法6 v-for列表渲染</title>
    <script src="https://unpkg.com/vue@3"></script>
</head>
<body>
    <div id="app">
        <h1>列表渲染主要是通过v-for指令来实现的</h1>
        <h1>知识点1：迭代普通数组</h1>
            <ul>
                <li v-for="item in times">1</li>
                
            </ul>
            <ul>
                <li v-for="item in flowers">{{item}}</li>
            </ul>
        <h1>知识点2：迭代对象数组</h1>
            <ul>
                <li v-for="(item,index) in users">{{item.name}}---{{index}}</li>
            </ul>
        <h1>知识点3：迭代对象里的属性</h1>
        <ul>
            <li v-for="(val,key) in users">{{key}}---{{val}}</li>
        </ul>
        <h1>知识点4：迭代数字</h1>
        <ul v-for="item in 10">{{item}}</ul>
        <h1>知识点5：关于key属性</h1>
            ID:<input type="text" v-model="id">
            NAME:<input type="text" v-model="name">
            <button>添加</button>
            <button>删除</button>
            <br>
            我新添加的id是{{id}}，我新添加的name是{{name}}
            
            <table>
                <tr v-for="item in users">
                    <td><input type="checkbox"></td>
                    <td>{{item.id}}</td>
                    <td>{{item.name}}</td>
                </tr>
            </table>
            <br><br><br>
    </div>
</body>
</html>
<script>
    const appConn = Vue.createApp({
        data() {
            return {
                times:5,
                flowers:['1','2','3','4','5'],
                users:[{id:'001',name:'123'},{id:'002',name:'112'}]
            }
        },
    }).mount("#app")
</script>